package com.cy.pj.utils;

import com.cy.pj.pojo.ResultMessage;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class MessageUtils {
    public static String getMessage(boolean isSystemMessage,String forName,Object message){
        try{
            ResultMessage result = new ResultMessage();
            result.setMessage(isSystemMessage);
            result.setMessage(message);
            if(forName != null){
                result.setForName(forName);
            }
            ObjectMapper mapper = new ObjectMapper();
            return mapper.writeValueAsString(result);
        }catch (JsonProcessingException e){
            e.printStackTrace();
        }
        return null;
    }
}
